﻿using System;
using System.Windows.Forms;

namespace Game.Client
{
    static class ControlExtension
    {
        public static void DoActionCrossThreads(this Control control, Action act)
        {
            try
            {
                if (control.IsHandleCreated)
                {
                    control.Invoke(new MethodInvoker(act));
                }
                else
                {
                    act();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);

            }
        }

        public static void FlashWindow(this Form form)
        {
            FlashWindow(form.Handle, true);
        }

        [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "FlashWindow")]
        public static extern bool FlashWindow(IntPtr hWnd, bool bInvert);
    }
}
